package cn.tedu.ivos.repair.controller;

import cn.tedu.ivos.base.response.JsonResult;
import cn.tedu.ivos.repair.pojo.dto.RepairQuery;
import cn.tedu.ivos.repair.pojo.dto.RepairSaveParam;
import cn.tedu.ivos.repair.pojo.vo.RepairVO;
import cn.tedu.ivos.repair.service.RepairService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Slf4j
@RequestMapping("/v1/repair")
public class RepairController {
    @Autowired
    RepairService repairService;
    @PostMapping("/save")
    public JsonResult save(RepairSaveParam repairSaveParam){
        log.debug("开始处理添加报修业务，{}",repairSaveParam);
        repairService.save(repairSaveParam);
        return JsonResult.ok();
    }
    @GetMapping("/select")
    public JsonResult select(RepairQuery repairQuery){
        log.debug("开始处理添加报修业务");
        List<RepairVO> list = repairService.select(repairQuery);
        return JsonResult.ok(list);
    }

    @PostMapping("/delete/{id}")
    public JsonResult delete(@PathVariable Long id ){
        log.debug("开始处理删除报修业务");
        repairService.delete(id);
        return JsonResult.ok();
    }

}
